// 1. 引入events模块 
const events = require("events");
const EventEmitter = events.EventEmitter;
console.log(EventEmitter);
// 2. 实例化对象
var eventObj = new events.EventEmitter();
console.log(eventObj);

eventObj.on("hello" , (args) => {
    console.log(args);
    console.log("node events");
})

//通过emit来触发事件 , emit(<eventName> , data)  , 对于这个data当做是 on中的回调函数的是参数传入
eventObj.emit("hello" , "test");